package com.huawei.esdk.tp.domain.model;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.huawei.esdk.platform.common.SDKErrorCode;
import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.platform.common.utils.ApplicationContextUtil;
import com.huawei.esdk.platform.nemgr.itf.IDeviceManager;
import com.huawei.esdk.tp.common.constants.TPConstant;
import com.huawei.esdk.tp.device.smc.IConferenceControlCapability;
import com.huawei.esdk.tp.device.smc.IConferenceManagerCapability;
import com.huawei.esdk.tp.domain.model.bean.ConfStatus;
import com.huawei.esdk.tp.domain.model.bean.ContinuousPresenceCapability;
import com.huawei.esdk.tp.domain.model.bean.ContinuousPresenceParam;

/**
 * 会议类的基类
 * 
 * @author j00160659
 * 
 */
public class Conference
{
    private String id;

    private String name;

    private String accessCode;

    private List<SiteInConference> sites;

    private Date beginTime;

    private Integer length;

    private ConfStatus status;
    
    private ConferenceStatus conferenceStatus;

    // 会议的速率
    private String rate;

    private static IDeviceManager deviceManager = (IDeviceManager) ApplicationContextUtil
            .getBean("deviceManager");

    public static IDeviceManager getDeviceManager()
    {
        return deviceManager;
    }

    public static void setDeviceManager(IDeviceManager deviceManager)
    {
        Conference.deviceManager = deviceManager;
    }

    public Conference(String id)
    {
        this.id = id;
    }

    /**
     * @return
     * @see SMC:GetContinuousPresenceInfo
     */
    public SDKResult<ContinuousPresenceCapability> getContinuousPresenceCapability()
    {
        return new SDKResult<ContinuousPresenceCapability>();
    }

    /**
     * @param continuousPresenceType
     * @return
     * @see SMC:GetContinuousPresenceParam
     */
    public SDKResult<ContinuousPresenceParam> getContinuousPresenceParam(
            String continuousPresenceType)
    {
        return new SDKResult<ContinuousPresenceParam>();
    }

    /**
     * @param continuousPresenceType
     * @param param
     * @return
     * @see SMC:SetContinuousPresence
     */
    public SDKErrorCode setContinuousPresenceParam(
            String continuousPresenceType, ContinuousPresenceParam param)
    {
        return new SDKErrorCode();
    }

    public Site getSiteInConference(String siteUri)
    {
        return new SiteInConference(id, siteUri);
    }

    // ///////////////////////////////////////////////////////////////
    /**
     * @param externalConfIds
     * @return
     * @see SMC:QueryConferenceId
     */
    public static SDKResult<Map<String, Integer>> queryConferenceIdByExternalId(
            List<String> externalConfIds)
    {
        return new SDKResult<Map<String, Integer>>();
    }

    /**
     * @param confIds
     * @return
     * @throws SDKException 
     * @see SMC:QueryConferencesStatus
     */
    public static SDKResult<List<Conference>> queryConferencesStatus(
            List<String> confIds) throws SDKException
    {
        IConferenceManagerCapability confMgr = deviceManager
                .getDeviceServiceProxy(TPConstant.DEV_ID_SMC,
                        IConferenceManagerCapability.class);
        SDKResult<List<Conference>> result = confMgr.queryConfStatus(confIds);
        return result;
    }

    /**
     * 终止会议 * @return
     * @throws SDKException 
     */
    public SDKErrorCode deleteConference() throws SDKException
    {
        IConferenceControlCapability confCtrl = deviceManager
                .getDeviceServiceProxy(TPConstant.DEV_ID_SMC,
                        IConferenceControlCapability.class);
        SDKErrorCode code = confCtrl.deleteConf(getId(),beginTime);
        return code;
    }
    
    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public List<SiteInConference> getSites()
    {
        return sites;
    }

    public void setSites(List<SiteInConference> sites)
    {
        this.sites = sites;
    }

    public String getAccessCode()
    {
        return accessCode;
    }

    public void setAccessCode(String accessCode)
    {
        this.accessCode = accessCode;
    }

    public Date getBeginTime()
    {
        if (null != beginTime)
        {
            return (Date)beginTime.clone();
        }
        else
        {
            return null;
        }
    }

    public void setBeginTime(Date beginTime)
    {
        if (null != beginTime)
        {
            this.beginTime = (Date)beginTime.clone();
        }
    }

    public Integer getLength()
    {
        return length;
    }

    public void setLength(Integer length)
    {
        this.length = length;
    }

    public String getRate()
    {
        return rate;
    }

    public void setRate(String rate)
    {
        this.rate = rate;
    }

    public ConfStatus getStatus()
    {
        return status;
    }

    public void setStatus(ConfStatus status)
    {
        this.status = status;
    }

    public ConferenceStatus getConferenceStatus()
    {
        return conferenceStatus;
    }

    public void setConferenceStatus(ConferenceStatus conferenceStatus)
    {
        this.conferenceStatus = conferenceStatus;
    }

}
